package user_service

import (
	"bird/internal/api/repository/db_repo"
	"bird/internal/api/repository/db_repo/driver_info_repo"
	"bird/internal/api/repository/db_repo/user_info_repo"
	"bird/internal/pkg/core"
)

func (s *service) BanUser(ctx core.Context, phoneNo string) (err error) {
	data := map[string]interface{}{
		"status": 0, //禁用状态
	}

	qb := user_info_repo.NewQueryBuilder()
	qb.WherePhoneNo(db_repo.EqualPredicate, phoneNo)
	err = qb.Updates(s.db.GetDbW().WithContext(ctx.RequestContext()), data)

	if err != nil {
		return
	}

	dqb := driver_info_repo.NewQueryBuilder()
	dqb.WherePhoneNo(db_repo.EqualPredicate, phoneNo)
	err = dqb.Updates(s.db.GetDbW().WithContext(ctx.RequestContext()), data)

	return
}
